<template>
    <el-card shadow="always" class="login_box">
        <el-form label-position="left" label-width="50px" :model="form">
            <p style="color:#444">故障报修维护系统</p>
            <br><br>
            <el-form-item label="账号">
                <el-input v-model="form.userCode"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input type="password" v-model="form.password"></el-input>
            </el-form-item>
            <br>

            <el-button type="primary" @click="login">登录</el-button>
            <el-button type="primary" plain>注册</el-button>


        </el-form>

    </el-card>
</template>

<script>

    import FrmFeService from '../service/FrmFeService'

    export default {
        name: "Login",
        data() {
            return {
                form: {
                    userCode: "",
                    password: ""
                }
            }
        },
        methods:{
            login(){
                let app=this
                FrmFeService.login(this.form.userCode,this.form.password).then(resp=>{
                    if(resp.data.stateCode!='OK')
                    {
                        alert("登录失败："+resp.data.msg)
                    }
                    else {
                        app.$router.push("/home")
                    }
                }).catch(e=>{
                    alert("登录失败："+e)
                })

            }
        }
    }
</script>

<style lang="scss" scoped>
    .login_box {
        width: 420px;

        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        padding: 20px;
        button {
            margin: 0 20px;
        }
    }

</style>